<template>
  <span>{{ JSON.stringify(userInfo) }}</span>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="questionId" label="ID" width="80" />
    <el-table-column prop="title" label="Title" width="180" />
    <el-table-column prop="difficulty" label="Difficulty" width="120" />
    <el-table-column prop="timeLimit" label="Time Limit (sec)" width="180" />
    <el-table-column prop="spaceLimit" label="Space Limit (MB)" width="180" />
    <el-table-column prop="content" label="Content"  width="180"/>
<!--    <el-table-column fixed="right" label="Operations" min-width="120">-->
<!--      <template #default="scope">-->
<!--        <el-button link type="primary">Edit</el-button>-->
<!--      </template>-->
<!--    </el-table-column>-->
  </el-table>
</template>

<script lang="ts" setup>
import {ref,onMounted} from "vue";
import axios from "axios";
// import dd from "gdt-jsapi"//专有钉钉
import * as dingtalk from 'dingtalk-jsapi';
const tableData = ref([])

const userInfo = ref(null);

// const initData = async () => {
//   const {data} = await axios.get('http://localhost:8080/question/list' )
//   tableData.value = data.data
//
//   console.log(data.data)
// }


onMounted(()=>{
  console.log(userInfo.value)
  // this.initData
  dingtalk.runtime.permission.requestAuthCode({
    corpId: 'ding251552c72e09399524f2f5cc6abecb85',
  }).then(res => {
    console.log(res.code)
    // 调用接口
    axios.get('http://localhost:8088/getToken?code='+ res.code ).then(res=>{
      userInfo.value = res.data.data.result
      sessionStorage.setItem('userInfo', JSON.stringify(userInfo.value));
      const userInfoData = JSON.parse(sessionStorage.getItem('userInfo'));
      console.log(userInfoData)
    })
  })
})
</script>

<style scoped>
</style>
